package homewoek12月30号.homework.h1h2;

import org.apache.commons.io.FileUtils;

import java.io.File;
import java.io.IOException;
import java.util.List;
import java.util.Scanner;

public class H2 {
    public static void main(String[] args) throws Exception {
        run1();
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入：");
        String str = sc.next();
        String str1 = getStr(str);
        System.out.println(str1);
    }

    private static String  getStr(String str) throws IOException {
        List<String> list = FileUtils.readLines(new File("src/czxy/com/homework/h1h2/d.txt"));
        for (String s : list) {
            if (s.contains(str)){
                return s;
            }
        }
        return null;
    }

    private static void run1() throws IOException {
        List<String> list = FileUtils.readLines(new File("src/czxy/com/homework/h1h2/c.txt"));
        int a=0;
        for (int j = 0; j < list.size(); j++) {
            String[] arr = list.get(j).split("。");
            for (int i = 0; i < arr.length; i++) {
                a++;
                if (a==1){
                    FileUtils.writeStringToFile(new File("src/czxy/com/homework/h1h2/d.txt"),a+")."+arr[i],false);
                }else {
                    FileUtils.writeStringToFile(new File("src/czxy/com/homework/h1h2/d.txt"),"\n"+a+")."+arr[i],true);
                }
            }
        }
    }
}
